package errorx

const (
	ErrorDefaultBadRequest       = 400
	ErrorDefaultUnanthorized     = 401
	ErrorDefaultForbidden        = 403
	ErrorDefaultNotFound         = 404
	ErrorDefaultMethodNotAllowed = 405
	ErrorInternet                = 500

	ErrorDefault           = 1001
	ErrorAccountOrPassword = 1002
	ErrorNotFound          = 1004
	ErrorImportStaffData   = 1005
	ErrorDataExists        = 1006
)

var errText map[int]string = map[int]string{
	ErrorDefaultBadRequest:       "bad request",
	ErrorDefaultUnanthorized:     "unauthorized",
	ErrorDefaultForbidden:        "access denied",
	ErrorDefaultNotFound:         "not found.",
	ErrorDefaultMethodNotAllowed: "method not allowed",
	ErrorInternet:                "internet error",

	ErrorDefault:           "未定义错误",
	ErrorAccountOrPassword: "账户或密码错误",
	ErrorNotFound:          "数据不存在",
	ErrorImportStaffData:   "人群资源导入表格数据有误",
	ErrorDataExists:        "数据已存在",
}

func text(code int) string {
	if s, ok := errText[code]; ok {
		return s
	} else {
		return errText[ErrorDefault]
	}
}
